<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  
  <head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
      <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
      <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  
  <body>
  
  
  
    <div class="x-body">
      <div class="layui-row">
       
      </div>
      <table class="layui-table">
        <thead>
          <tr>
          	<th>操作</th>
            <th>时间</th>
            <th>报案人</th>
            <th>接案人</th>
            <th>委托公司</th>
            <th>查勘人</th>
            <th>状态</th>
            <th>垫付金</th>
            <th>赔偿金</th>
            <th>核赔人</th>
            <th>垫付人</th>
            <th>操作人</th>
            <th>操作</th>
        </thead>
        <tbody>
          
         
        </tbody>
      </table>
      <div class="page">
        <div>
          <a class="first" >&lt;&lt;</a>
           <a class="layout" >1/1</a>
          <a class="next" >&gt;&gt;</a>
          <span id="count"></span>
        </div>
        
      </div>

    </div>
    <script>
      /* layui.use('laydate', function(){
        var laydate = layui.laydate;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });
      }); */

     
      /*用户-删除*/
      function member_del(obj,id){
          layer.confirm('确认要恢复吗？',function(index){
              //发异步删除数据
           $.getJSON(
        		"update.do",
        		{"id":id},
        		function(i){
        			if(i>0){
        				 layer.msg('已恢复!',{icon:1,time:1000});
        				 //刷新当前页面
        				 window.location.reload();
        				 //刷新父页面
        				 parent.location.reload();
        				 
        			}else{
        				layer.msg('操作有误!',{icon:5,time:1000});
        			}
        		}
           );//ajax方法结束
          
           layer.msg('已恢复!',{icon:1,time:1000});
        
          });
         
      }

	//

     $(function(){
			//初始化值
			init(1);
		});
	//转换时间
 	function add0(m){return m<10?'0'+m:m }
 	//时间戳转化成时间格式
 	function timeFormat(timestamp){
 	  //timestamp是整数，否则要parseInt转换,不会出现少个0的情况
 	    var time = new Date(timestamp);
 	    var year = time.getFullYear();
 	    var month = time.getMonth()+1;
 	    var date = time.getDate();
 	    var hours = time.getHours();
 	    var minutes = time.getMinutes();
 	    var seconds = time.getSeconds();
 	    return year+'-'+add0(month)+'-'+add0(date)+' '+add0(hours)+':'+add0(minutes)+':'+add0(seconds);
 	}
 	//
 //初始化从后台调用数据 传入的参数是第几页
    	function init(pageNo){
    		$.getJSON(
    				"managebaoanlist.do",
    				{"pageNo":pageNo},
    				function (list){
    					 $("#count").html("共有数据："+list.length+"条");
    					$("table tr:not(:first)").remove();
    					$(list).each(function(index,obj){
    						var reportState=null;//报案状态
    						var advancePrices=obj.advancePrices;//垫付金
    						var compensate=obj.compensate;//赔偿金
    						var auditName=obj.auditName;//核赔人
    						var payName=obj.payName;//垫付人
    						var companyName=obj.companyName;//委托公司
    						var surveyorsName=obj.surveyorsName;//勘测人
    						var state=obj.updateTime;//修改时间
    						var time=null;//操作时间
    						if(state!=null){
    							state="修改";
    							time=timeFormat(obj.updateTime);
    						}else{
    							state="新增";
    							time=timeFormat(obj.createTime);
    						}
    						if(companyName == null || companyName==""){
    							companyName="/"
    						}
    						if(surveyorsName == null || surveyorsName==""){
    							surveyorsName="/"
    						}
    						if(advancePrices == null || advancePrices==0){
    							advancePrices="/"
    						}
    						if(compensate == null || compensate==0){
    							compensate="/"
    						}
    						if(auditName == null || auditName==0){
    							auditName="/"
    						}
    						if(payName == null || payName==0){
    							payName="/"
    						}
    						if(obj.reportState==1){
    							reportState="报案中";
    						}
    						if(obj.reportState==2){
    							reportState="勘测中";
    						}
    						if(obj.reportState==5){
    							reportState="核赔中";
    						}
    						if(obj.reportState==8){
    							reportState=" 垫付申请";
    						}
    						if(obj.reportState==10){
    							reportState="垫付通过";
    						}
    						
    						//将数据 写道到  创建tr 中 
    						var tr ="<tr>"
    							+"<td>"+state+"</td>"
    							+"<td>"+time+"</td>"
    							+"<td>"+obj.reportName+"</td>"
    							+"<td>"+obj.serviceName+"</td>"
    							+"<td>"+companyName+"</td>"
    							+"<td>"+surveyorsName+"</td>"
    							+"<td>"+reportState+"</td>"
    							+"<td>"+advancePrices+"</td>"
    							+"<td>"+compensate+"</td>"
    							+"<td>"+auditName+"</td>"
    							+"<td>"+payName+"</td>"
    							+"<td>"+obj.loadName+"</td>"
    							+"<td class='td-manage'>"
    							+"<button  class='layui-btn-danger layui-btn layui-btn-xs'  onclick=\"member_del(this,"+obj.recordedId+")\">"
    							+"恢复</button>"
    							+"<button class='layui-btn layui-btn layui-btn-xs'  onclick=\"x_admin_show('详情','baoanlist_xh.html?id="+obj.recordedId+"')\">"
    							+"详情</button>"
    							+"</td>"
    							+"</tr>";
    							$("tbody").append(tr);
    							
    						
    					});//循环
    					
    					
    					//最后一个数据不可恢复
    					//$("tbody>tr:last-child td:last-child").html("最新数据");
    					$("tbody>tr:last-child td:last-child button:first").remove();
    					//分页
    					/* $("#count").html("共有数据："+pageInfo.total+"条");
    					$(".layout").html(pageInfo.pageNo/pageInfo.pageTotal);
    					if(pageNo==1){
        					$(".first").removeAttr('href');
    					}else{
        					$(".first").attr("href","javascript:init("+(pageNo-1)+")");
    					}
    					if(pageNo==pageInfo.pageTotal){
    						$(".next").removeAttr('href');
    					}else{
        					$(".next").attr("href","javascript:init("+(pageNo+1)+")");
    					}
    					
    					 */
    					
    				}//回调函数方法
    		
    		);//ajax方法
    		
    	};
    </script>
   
  </body>

</html>